\name{GetStationName}
\alias{GetStationName}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Get the PRBO full length descriptive station name }
\description{
  This function provides PRBO's full length descriptive station name from either a unique SamplingUnitID or the point count station code.
}
\usage{
GetStationName(station = NULL, SamplingUnitID = NULL, batch = FALSE, ...)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{station}{ A vector of PRBO station codes }
  \item{SamplingUnitID}{ A vector of PRBO SamplingUnitIDs }
  \item{batch}{Boolean variable to denote whether this process should be done in batch mode.  Not yet implemented.}
  \item{\dots}{Additional variables that can get passed through to underlying functions}}
\details{
  This function will query the PRBOdb database and retrieve the
  PRBO site name (descriptive) for a given set of either unique
  point identifiers (SamplingUnitIDs) or the point count station
  codes.
}
\value{
  Returns a vector of long descriptive site names of the same length as that provided for the search.
}
\references{ ~put references to the literature/web site here ~ }
\author{ Mark Herzog \email{mherzog@prbo.org} }

\seealso{ \code{\link{GetSamplingUnitID}}, \code{\link{GetPointCountStationID}} }
\examples{
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--    or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(station=NULL, SamplingUnitID=NULL, batch=FALSE, ...) {
    if (is.null(station) & is.null(SamplingUnitID)) stop ("Either a station or a SamplingUnitID must be provided.")
    if (!is.null(station)) {
        station.list<-paste("'",station,"'",sep="",collapse=",")
        query<- paste(  "SELECT DISTINCT SamplingUnitName",
                        "FROM SamplingUnit",
                        "WHERE SamplingUnitTypeCd != 'PointCountStation'",
                        "AND PointCountStationID IN (",station.list,")"
        )
        query.results<-fetch(dbSendQuery(db<-PRBOdbConnect(group="PRBOdb", ...),query),n=-1)
        SamplingUnitName<-query.results[,1]
        dbDisconnect(db)
    } else {
        station.list<-paste("'",SamplingUnitID,"'",sep="",collapse=",")
        query<-paste(   "SELECT DISTINCT SamplingUnitName",
                        "FROM SamplingUnit",
                        "WHERE SamplingUnitID in (",station.list,")",
                        "AND SamplingUnitTypeCd != 'PointCountStation'"
                )
        query.results<-fetch(dbSendQuery(db<-PRBOdbConnect(group="PRBOdb", ...),query),n=-1)
        SamplingUnitName<-paste("'",query.results[,1],"'",sep="",collapse=",")
        dbDisconnect(db)
    }
    return(SamplingUnitName)        
  }
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ data }
